const addService = require('../service/user')
//增加
const addUserController = async(ctx,next)=>{
   let result = await addService.addUserService(ctx.request.body)
   console.log(result)
    if(result){
        ctx.body={
            code:200,
            mag:'addUserController,success',
            data:result
        }
    }else {
        ctx.body={
            code:403,
            mag:'params'
        }
    }
}
//删除
const deleteUserController = async(ctx,next)=>{
    let result = await addService.addUserService(ctx.params.id);
    if(result){
        ctx.body={
            code:200,
            mag:'deleteUserController,success',
            data:result
        }
    }else {
        ctx.body={
            code:403,
            mag:'params'
        }
    }
 }


const getListController = async(ctx,next)=>{
    let result = await addService.getListService()
    console.log(result,'11111')
    ctx.body={
        code:200,
        msg:'success'
    }
}

const addListController = async(ctx,next)=>{
    let result = await addService.addListService(ctx.request.body)
    console.log(result,'22222')
    if(result){
        ctx.body={
            code:200,
            msg:'success',
            data:null
        }
    }else {
        ctx.body={
            code:403,
            msg:'params error',
            data:null
        }
    }
    
}


module.exports={
    addUserController,
    deleteUserController,
    getListController,
    addListController,
}